package com.youngwang.threadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author youngwang
 *         Date: 2016/8/31
 */
public class SimpleThreadPool {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newScheduledThreadPool(5);
        for (int i = 0; i < 10; i++) {
            Runnable worker = new WorkerThread("" + i);
            executorService.execute(worker);
        }
        if(!executorService.isShutdown()){
            executorService.shutdown();
        }
        while (!executorService.isTerminated()){

        }
        System.out.println("Finished All Threads.");
    }
}
